<?php
class EditType extends Action {
	public function execute($params) {
		check_login ( ADMIN_LOGIN_PAGE );
		$tid = irqst ( 'tid' );
		if (empty ( $tid )) {
			$data ['page_tip_info'] = "<strong>出错啦!</strong>tid为空，系统无法加载对应页面类型。";
		} else {
			$type = sess_del ( 'page_type_info', false );
			if (! $type) {
				$typeModel = new WebPageTypeModel ();
				$type = $typeModel->read ( $tid );
			}
			if ($type == false) {
				$data ['page_tip_info'] = "<strong>出错啦!</strong>tid为{$tid}的页面类型不存在。";
			} else {
				$data = $type;
				$data ['page_tip_info'] = sess_del ( 'page_tip_info' );
			}
		}
		$data ['alert_cls'] = 1 == irqst ( 'suc', 0 ) ? 'alert-success' : 'alert-error';
		$data ['error'] = sess_del ( 'page_type_error', array () );
		$data ['error_cls'] = ModelValidator::getErrorCls ( $data ['error'] );
		$data ['editing'] = 1;
		$data ['nodes'] = json_encode ( WebTemplateModel::getTemplateTreeData () );
		return new SmartyView ( $data, 'theme/AddType' );
	}
}